﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyKhachSan.BusinessObject;
using System.Security.Cryptography;
namespace QuanLyKhachSan
{
    class Utilities
    {
        public static string NextID(string lastID, string prefixID)
        {
            int nextID = int.Parse(lastID.Remove(0, prefixID.Length)) + 1;
            int lengthNumberID = lastID.Length - prefixID.Length;
            string zeroNumber = "";
            for (int i = 0; i < lengthNumberID; i++)
            {
                if (nextID < Math.Pow(10, i))
                {
                    for (int j = 1; j < lengthNumberID; j++)
                    {
                        zeroNumber += "0";
                    }
                    return prefixID + zeroNumber + nextID.ToString();
                }
            }
            return prefixID + nextID;
        }


        public static string MaHoaMD5(string text) {
            MD5CryptoServiceProvider _md5Hashar = new MD5CryptoServiceProvider();
            byte[] bs = Encoding.UTF8.GetBytes(text);
            bs = _md5Hashar.ComputeHash(bs);
            StringBuilder s = new StringBuilder();
            foreach(byte b in bs){
                s.Append(b.ToString("x2"));
            }
            return s.ToString();
        }
        #region thông tin user
        public static NhanVienBO user = new NhanVienBO();
         
        #endregion
    }
}
